package com.aldd.controller;

import com.aldd.entity.Book;
import com.aldd.mapper.BookMapper;
import com.aldd.service.BookService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

import java.util.List;

@Data
@Controller
public class BookController {
    @Autowired
    private BookService bookService;

    public List<Book> selectAllBook() {
        return bookService.selectAllBook();
    }

    public Book selectBookById(int id) {
        return bookService.selectBookById(id);
    }

    public String deleteBook(int id) {
        return bookService.deleteBook(id) ? "删除成功" : "删除失败";
    }

    public String insertBook(Book book) {
        return bookService.insertBook(book) ? "添加成功" : "添加失败";
    }

    public String updateBook(Book book) {
        return bookService.updateBook(book) ? "修改成功" : "修改失败";
    }
}
